<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="pojo.Brand" %><%--  在第一行加入【JSP指令：page,include,taglib】 --%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" ></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>品牌管理页</title>
    <style type="text/css">
        table{
            width: 100%;
            border-collapse: collapse;

        }
        input::-webkit-input-placeholder{
            color:rgba(78,125,243,0.56);
            border-color:rgba(78,125,243,0.56);
        }
        table td{
            border: 1px solid rgba(176, 103, 196, 0.75);
            text-align: center;
            color: rgba(97, 196, 225, 0.73);
        }
        table tr{

        }
        table td a{
            text-decoration: none;
            color: #f15454;
        }
        form input{
            color:rgba(78,125,243,0.56);
            border-color:rgba(78,125,243,0.56);
        }
        form button{
            color:rgba(78,125,243,0.56);
            border-color:rgba(78,125,243,0.56);
            border-radius: 10px;
        }
        /*  HTML5已不支持   border="1" cellspacing="0" width="800" */
    </style>
</head>
<body style="background-color: rgba(245,202,206,0.24)">
<h1 style="color:#f15454;">${LOGIN_USER.username},欢迎您
    <a href="${ctx}/logout" style="text-decoration: none; color: rgba(77,88,255,0.63)">[注销]</a>
</h1>



<form action="${ctx}/SelectStatusAllServlet" method="get" style="color: rgb(136,129,129)">
    状态:
    <select name="status"style="color:rgba(78,125,243,0.56); border-color:rgba(78,125,243,0.56);">
        <option value="3">全部状态</option>
        <option value="0">禁用</option>
        <option value="1">启用</option>
    </select>
    品牌名称:
    <input type="text" value="" placeholder="请输入查询关键词" name="word">
    <button type="submit" value="查询">查询</button>
    <button type="reset" value="重置">重置</button>
    <input type="button" value="批量删除" name="ids"  style="margin-left: 935px;display: inline-block;border-radius: 10px;">
    <input type="button" value="新增" id="addBtn" style="border-radius: 10px;">
</form>

<hr>
<table >
    <tr style="color:rgba(156,84,192,0.83)">
        <th>选择</th>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${pageBeans}" var="brand">
        <tr>
            <td><input type="checkbox"></td>
            <td>${brand.id}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <td>
                <c:if test="${brand.status == 1}">
                    启用
                </c:if>
                <c:if test="${brand.status == 0}">
                    禁用
                </c:if>
            </td>
            <td>
                <a href="${ctx}/toUpdate?id=${brand.id} ">修改</a>
                <a href="/brand-demo/DeleteServlet?id=${brand.id}" onclick="if(confirm('确定删除?')==false)return false;">删除</a>

            </td>
        </tr>
    </c:forEach>
    <c:forEach items="${pageBean.data}" var="brand">
        <tr>
            <td><input type="checkbox"></td>
            <td>${brand.id}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <td>
                <c:if test="${brand.status == 1}">
                    启用
                </c:if>
                <c:if test="${brand.status == 0}">
                    禁用
                </c:if>
            </td>
            <td>
                <a href="${ctx}/toUpdate?id=${brand.id}">修改</a>
                <a href="/brand-demo/DeleteServlet?id=${brand.id}" onclick="if(confirm('确定删除?')==false)return false;">删除</a>

            </td>
        </tr>
    </c:forEach>
</table>
<div>
    <jsp:include page="common/pageBar.jsp">
        <jsp:param name="url" value="/SelectAll"/>
    </jsp:include>
</div>
<div>
    <span style="color:#f15454;">当前在线人数是：${applicationScope.OnlineCount}</span>
</div>

</body>
<script>
    function getContextPath() {
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0,index+1);
        return result;
    }

    let addBtn = document.querySelector("#addBtn");
    addBtn.addEventListener('click',function (){
        window.location.href=getContextPath()+"/addBrand.jsp"
    })
</script>
</html>